//
//  MyAttendance.m
//  SchoolTask
//
//  Created by feel on 16/8/25.
//  Copyright © 2016年 sm. All rights reserved.
//

#import "MyAttendance.h"

@interface MyAttendance ()

@property (nonatomic,retain) UIView   *topView;
@property (nonatomic,retain) UILabel  *attendanceList; //显示 课程签到列表
@property (nonatomic,retain) UILabel  *classNameLb;    //课程
@property (nonatomic,retain) UILabel  *attendance;     //正常考勤
@property (nonatomic,retain) UILabel  *late;           //迟到
@property (nonatomic,retain) UILabel  *leave;          //早退
@property (nonatomic,retain) UILabel  *askLeave;       //请假
@property (nonatomic,retain) UILabel  *crunk;          //旷课
@property (nonatomic,retain) UILabel  *lineLabel;      //底部黄线

@end

@implementation MyAttendance

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        self.frame = [UIScreen mainScreen].bounds;
        [self setButton];
    }
    return self;
}

//设置按钮
- (void)setButton {
    
    _attendanceList = [[UILabel alloc]initWithFrame:CGRectMake(20, 30, 155, 150)];
    _attendanceList.text = @"课程签到列表";
    _attendanceList.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    _attendanceList.textColor = [UIColor colorWithRed:250/255.0 green:140/255.0 blue:0 alpha:1];
    
    NSArray *array = [NSArray arrayWithObjects:@"课程",@"正常考勤",@"迟到",@"早退",@"请假",@"旷课", nil];
    NSInteger buttonTag = 1000;
    CGFloat w = [UIScreen mainScreen].bounds.size.width/5;
    
    //设置底部移动的黄线
    _lineLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 200, w, 2)];
    _lineLabel.backgroundColor = [UIColor colorWithRed:250/255.0 green:190/255.0 blue:150/255.0 alpha:1];

    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 200, w*5, 2)];
    label.backgroundColor = [UIColor colorWithRed:170/255.0 green:170/255.0 blue:170/255.0 alpha:1];
    
    //创建button 5个
    for (NSInteger i = 0; i < 6; i++) {
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = CGRectMake(0 + w * i, 150 , w, 50);
        [button setTitle:array[i] forState:UIControlStateNormal];
        
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        
        [button setTitleColor:[UIColor colorWithRed:130/255.0 green:130/255.0 blue:130/255.0 alpha:1]forState:UIControlStateNormal];
        button.tag = buttonTag;
        button.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];


        buttonTag ++;
        [self addSubview:button];
        [self addSubview:label];
        [self addSubview:_lineLabel];
        [self addSubview:_attendanceList];
    }
    
}
- (void)buttonAction:(UIButton *)button {
    
    CGFloat w = [UIScreen mainScreen].bounds.size.width/5;
    CGFloat i = button.tag - 1000;
    _lineLabel.frame = CGRectMake(0 + w * i, 200 , w, 2);

    NSLog(@"button");

    if (button.tag == 1000) {
        
    }
}

@end
